package com.boatAnchorAssistant.service.controller.app;

import com.boatAnchorAssistant.pojo.param.login.AccountLoginParam;
import com.boatAnchorAssistant.pojo.vo.login.TokenVo;
import com.boatAnchorAssistant.service.service.in.LoginService;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * app/登录
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController()
@RequestMapping(value = "/login/app")
public class LoginAppController {


    private final LoginService service;

    public LoginAppController(LoginService service) {
        this.service = service;
    }

    /**
     *  账号登录
     * @return
     */
    @PostMapping("/accountLogin")
    public ApiResult<TokenVo> accountLogin(@RequestBody @Valid AccountLoginParam param){
        TokenVo vo = service.appLogin(param);
        return ApiResult.ok(vo);
    }

    /**
     * 刷新token
     *
     * @return
     */
    @GetMapping("/refresh")
    public ApiResult<TokenVo> refresh(){
        TokenVo refresh = service.refresh();
        return ApiResult.ok(refresh);
    }
}
